<?php
	class UserService 
	{     
	    static function authenticate()
		{
			if ($_SERVER['REQUEST_METHOD'] == 'POST') 
			{			
				$username = stripslashes($_POST['J_USERNAME']);
				$password = stripslashes($_POST['J_PASSWORD']);
				$user  = R::findOne( 'members', ' username = :username  and password = :password', array( ':username'=>$username ,':password'=>$password));
			   if (!empty($user))
				{
					 session_start();
					// store session data
					$_SESSION['isLogin']=true;
					header("location:dashboard.php");
				}			
			}     	
		}

		static function isLogin()
		{
			session_start();
			if(isset($_SESSION['isLogin']))
				return $_SESSION['isLogin'];
			else
				return false;
		}
	}   
